package com.zuosh.common;

import java.io.Serializable;

/**
 * Created by zuosh on 2016/4/29 0029.
 * 简单不分页数据返回所用结构
 */
public class ResponseHelper implements Serializable {
    /**
     * desc by kai
     * [ 返回结果集 ]
     */
    public static <T> RestResponse <T> buildResponse(String code, T data, String msg) {
        return new RestResponse(code, data, msg);
    }

    public static <T> RestResponse buildResponse(String code, T data) {
        return new RestResponse(code, data, null);
    }

    public static RestResponse buildResponse(String code) {
        return new RestResponse(code, null, null);
    }

    public static RestResponse buildResponse(String code, String msg) {
        return new RestResponse(code, null, msg);
    }

    public static class RestResponse<T> implements Serializable {
        private String code = RestResponseCode._200;//默认返回200
        private T data;
        private String msg;//请求结果说明

        public RestResponse(String code, T data, String msg) {
            this.code = code;
            this.data = data;
            this.msg = msg;
        }

        public String getCode() {
            return code;
        }

        public T getData() {
            return data;
        }

        public String getMsg() {
            return msg;
        }
    }

}
